/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Login.java
 *
 * Created on 20/10/2011, 23:54:07
 */
package threeds.GUI;

import java.awt.event.ActionEvent;
import javax.swing.JMenu;
import threeds.DAO.*;
import threeds.Model.*;
import java.awt.Component;
import java.awt.event.ActionListener;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JOptionPane;
import javax.swing.WindowConstants;
import threeds.Controller.ControllerProjetista;


/**
 *
 * @author Bernardo
 */
public class HomePort extends javax.swing.JFrame implements ActionListener{

    /** Creates new form Login 
    public HomePort() {
        super("ThreeDs - Database Data Dictionary");
        initComponents();
    }*/

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jdPane = new javax.swing.JDesktopPane();
        jPanel1 = new javax.swing.JPanel();
        ThreeDS = new javax.swing.JPanel();
        LinhaLabel = new javax.swing.Box.Filler(new java.awt.Dimension(700, 2), new java.awt.Dimension(700, 5), new java.awt.Dimension(500, 32767));
        ThreeDsLabel = new javax.swing.JLabel();
        DatabaseLabel = new javax.swing.JLabel();
        loginLabel = new javax.swing.JPanel();
        PainelLogin1 = new javax.swing.JPanel();
        PainelLogin2 = new javax.swing.JPanel();
        LoginLabel1 = new javax.swing.JLabel();
        emailuser = new javax.swing.JTextField();
        senhauser = new javax.swing.JPasswordField();
        entrarButton = new javax.swing.JButton();
        emailText = new javax.swing.JLabel();
        senhaText = new javax.swing.JLabel();
        jBRegistrar = new javax.swing.JButton();
        MenuSuperior = new javax.swing.JMenuBar();
        Arquivo = new javax.swing.JMenu();
        Sair = new javax.swing.JMenuItem();
        Editar = new javax.swing.JMenu();
        Ajuda = new javax.swing.JMenu();
        Sobre = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        ThreeDS.setBackground(new java.awt.Color(39, 232, 32));
        ThreeDS.setFont(new java.awt.Font("Times New Roman", 1, 36));
        ThreeDS.setPreferredSize(new java.awt.Dimension(1200, 200));

        LinhaLabel.setBackground(new java.awt.Color(204, 204, 204));
        LinhaLabel.setOpaque(true);

        ThreeDsLabel.setFont(new java.awt.Font("Times New Roman", 1, 56));
        ThreeDsLabel.setText("ThreeDs");

        DatabaseLabel.setFont(new java.awt.Font("Times New Roman", 2, 36));
        DatabaseLabel.setText("Database Data Dictionary");

        javax.swing.GroupLayout ThreeDSLayout = new javax.swing.GroupLayout(ThreeDS);
        ThreeDS.setLayout(ThreeDSLayout);
        ThreeDSLayout.setHorizontalGroup(
            ThreeDSLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ThreeDSLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(ThreeDSLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(LinhaLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(ThreeDSLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(DatabaseLabel))
                    .addComponent(ThreeDsLabel))
                .addContainerGap(490, Short.MAX_VALUE))
        );
        ThreeDSLayout.setVerticalGroup(
            ThreeDSLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(ThreeDSLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(ThreeDsLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(LinhaLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(DatabaseLabel)
                .addContainerGap(64, Short.MAX_VALUE))
        );

        loginLabel.setBackground(new java.awt.Color(196, 255, 171));
        loginLabel.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));
        loginLabel.setPreferredSize(new java.awt.Dimension(800, 300));

        PainelLogin1.setBackground(new java.awt.Color(255, 255, 255));
        PainelLogin1.setPreferredSize(new java.awt.Dimension(700, 200));

        PainelLogin2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        PainelLogin2.setPreferredSize(new java.awt.Dimension(650, 35));

        LoginLabel1.setFont(new java.awt.Font("Times New Roman", 0, 18));
        LoginLabel1.setText("Login");

        javax.swing.GroupLayout PainelLogin2Layout = new javax.swing.GroupLayout(PainelLogin2);
        PainelLogin2.setLayout(PainelLogin2Layout);
        PainelLogin2Layout.setHorizontalGroup(
            PainelLogin2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PainelLogin2Layout.createSequentialGroup()
                .addContainerGap(306, Short.MAX_VALUE)
                .addComponent(LoginLabel1)
                .addGap(301, 301, 301))
        );
        PainelLogin2Layout.setVerticalGroup(
            PainelLogin2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PainelLogin2Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(LoginLabel1))
        );

        emailuser.setFont(new java.awt.Font("Times New Roman", 0, 14));
        emailuser.setToolTipText("Insira aqui seu e-mail");
        emailuser.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED, null, new java.awt.Color(0, 0, 0), null, null));
        emailuser.setSelectedTextColor(new java.awt.Color(0, 0, 0));

        senhauser.setFont(new java.awt.Font("Tahoma", 1, 11));
        senhauser.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED, null, java.awt.Color.black, null, null));

        entrarButton.setBackground(new java.awt.Color(39, 232, 32));
        entrarButton.setText("Entrar");
        entrarButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                entrarButtonActionPerformed(evt);
            }
        });

        emailText.setFont(new java.awt.Font("Times New Roman", 1, 18));
        emailText.setText("E-mail*:");

        senhaText.setFont(new java.awt.Font("Times New Roman", 1, 18));
        senhaText.setText("Senha*:");

        javax.swing.GroupLayout PainelLogin1Layout = new javax.swing.GroupLayout(PainelLogin1);
        PainelLogin1.setLayout(PainelLogin1Layout);
        PainelLogin1Layout.setHorizontalGroup(
            PainelLogin1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PainelLogin1Layout.createSequentialGroup()
                .addGroup(PainelLogin1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(PainelLogin1Layout.createSequentialGroup()
                        .addGap(203, 203, 203)
                        .addGroup(PainelLogin1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(emailText)
                            .addComponent(senhaText))
                        .addGap(18, 18, 18)
                        .addGroup(PainelLogin1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(senhauser)
                            .addComponent(emailuser, javax.swing.GroupLayout.DEFAULT_SIZE, 302, Short.MAX_VALUE)))
                    .addGroup(PainelLogin1Layout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addComponent(PainelLogin2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(PainelLogin1Layout.createSequentialGroup()
                        .addGap(314, 314, 314)
                        .addComponent(entrarButton)))
                .addContainerGap(27, Short.MAX_VALUE))
        );
        PainelLogin1Layout.setVerticalGroup(
            PainelLogin1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PainelLogin1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(PainelLogin2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(13, 13, 13)
                .addGroup(PainelLogin1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(emailuser, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(emailText))
                .addGap(24, 24, 24)
                .addGroup(PainelLogin1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(senhauser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(senhaText))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 36, Short.MAX_VALUE)
                .addComponent(entrarButton)
                .addContainerGap())
        );

        jBRegistrar.setBackground(new java.awt.Color(39, 232, 32));
        jBRegistrar.setText("Registrar");
        jBRegistrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                registrarProjetista(evt);
            }
        });

        javax.swing.GroupLayout loginLabelLayout = new javax.swing.GroupLayout(loginLabel);
        loginLabel.setLayout(loginLabelLayout);
        loginLabelLayout.setHorizontalGroup(
            loginLabelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(loginLabelLayout.createSequentialGroup()
                .addGroup(loginLabelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(loginLabelLayout.createSequentialGroup()
                        .addGap(45, 45, 45)
                        .addComponent(PainelLogin1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(loginLabelLayout.createSequentialGroup()
                        .addGap(352, 352, 352)
                        .addComponent(jBRegistrar)))
                .addContainerGap(51, Short.MAX_VALUE))
        );
        loginLabelLayout.setVerticalGroup(
            loginLabelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(loginLabelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(PainelLogin1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jBRegistrar)
                .addContainerGap(56, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap(62, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(ThreeDS, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(68, 68, 68))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(loginLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(267, 267, 267))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(36, 36, 36)
                .addComponent(ThreeDS, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 56, Short.MAX_VALUE)
                .addComponent(loginLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(37, 37, 37))
        );

        MenuSuperior.setFocusTraversalPolicyProvider(true);

        Arquivo.setText("Arquivo");

        Sair.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F4, java.awt.event.InputEvent.ALT_MASK));
        Sair.setText("Sair");
        Sair.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SairActionPerformed(evt);
            }
        });
        Arquivo.add(Sair);

        MenuSuperior.add(Arquivo);

        Editar.setText("Editar");
        MenuSuperior.add(Editar);

        Ajuda.setText("Ajuda");

        Sobre.setText("Sobre");
        Sobre.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SobreActionPerformed(evt);
            }
        });
        Ajuda.add(Sobre);

        MenuSuperior.add(Ajuda);

        setJMenuBar(MenuSuperior);
        MenuSuperior.getAccessibleContext().setAccessibleParent(this);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void SobreActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SobreActionPerformed

        JOptionPane.showMessageDialog(null, "ThreeDs - Database Data Dictionary\n"                 + "Copyright 2011 - Universidade de Brasilia\n" + "Versao: 1.0", "Sobre", JOptionPane.PLAIN_MESSAGE);     }//GEN-LAST:event_SobreActionPerformed

    private void SairActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SairActionPerformed

        
        System.exit(0);     }//GEN-LAST:event_SairActionPerformed

    private void entrarButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_entrarButtonActionPerformed
        
        ControllerProjetista sessao = new ControllerProjetista(emailuser.getText(), senhauser.getText());
        if(sessao.logar())
        {    MainPort mp = new MainPort();
             mp.setVisible(true);
             this.dispose();
        }
        else{
             JOptionPane.showMessageDialog(null,"Usuário não encontrado!");
             //TODO Linpar os campos
        }
    }//GEN-LAST:event_entrarButtonActionPerformed

    private void registrarProjetista(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_registrarProjetista
        
        //jPanel projetistasPort = new JFrame();
        //projetistasPort.setVisible(true);
        
        
    }//GEN-LAST:event_registrarProjetista

    //cria objeto jdPane, do tipo JDesktopPane. Ele vai dentro d JFrame
   //public JDesktopPane jdPane = new JDesktopPane();

   ///Tela telaCadCliente, telaCadFornecedor, telaCadProduto;

   //método construtor da aplicação
    public HomePort() {
       //"pegue o conteúdo do painel" - adiciona o jDesktopPane ao JFrame (janela principal
       getContentPane().add(jdPane);
       
        //adiciona o menu cadastro à barra de menus (jmPrincipal)
        //MenuSuperior.add(Arquivo);
        
       //adiciona o item cliente ao menu cadastro
       //jmCadastro.add(jmCadCliente);

       //adiciona o item fornecedor ao menu cadastro
       //jmCadastro.add(jmCadFornecedor);

       //"ajusta" a barra de menu dentro da janela principal
      // setJMenuBar(jmPrincipal);

       //adiciona actionlistener ao item "cliente" do menu, 
       //para que os eventos sejam tratados
       //jmCadCliente.addActionListener(this);
       
       //adiciona o actionlistener ao item "fornecedor do menu
       //jmCadFornecedor.addActionListener(this);

       setSize(800,600);
       setVisible(true);
    }
   //método main instancia o objeto menu A inicialização fica com o construtor da classe	
   public static void main(String args[]) {
        HomePort menu = new HomePort();

        /* Create and display the form 
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new HomePort().setVisible(true);
            }
        });*/
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenu Ajuda;
    private javax.swing.JMenu Arquivo;
    private javax.swing.JLabel DatabaseLabel;
    private javax.swing.JMenu Editar;
    private javax.swing.Box.Filler LinhaLabel;
    private javax.swing.JLabel LoginLabel1;
    private javax.swing.JMenuBar MenuSuperior;
    private javax.swing.JPanel PainelLogin1;
    private javax.swing.JPanel PainelLogin2;
    private javax.swing.JMenuItem Sair;
    private javax.swing.JMenuItem Sobre;
    private javax.swing.JPanel ThreeDS;
    private javax.swing.JLabel ThreeDsLabel;
    private javax.swing.JLabel emailText;
    private javax.swing.JTextField emailuser;
    private javax.swing.JButton entrarButton;
    private javax.swing.JButton jBRegistrar;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JDesktopPane jdPane;
    private javax.swing.JPanel loginLabel;
    private javax.swing.JLabel senhaText;
    private javax.swing.JPasswordField senhauser;
    // End of variables declaration//GEN-END:variables

    @Override
    public void actionPerformed(ActionEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
